<template>
  <div class="index">
    <h1>TEST1</h1>
  </div>
</template>

<script type="text/ecmascript-6">
  import axios from 'axios';
  import NodeRSA from 'node-rsa';

  /**
   * @date 2018/9/3 10:00
   *
   *
   **/
  export default {
    name: 'Index',
    data() {
      return {}
    },
    mounted() {
      this.$nextTick(async () => {

        const {data: {key, data}} = await axios.get('/api');

        const rsa = new NodeRSA("-----BEGIN PUBLIC KEY-----\n" + key + "-----END PUBLIC KEY-----\n");

        rsa.setOptions({encryptionScheme: 'pkcs1'});

        const out = rsa.decryptPublic(data, 'utf-8');

        alert(out)
      })
    },
    methods: {}
  }
</script>

<style scoped>
  .index {
  }
</style>
